<!doctype html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      layout:decorator="base"
      th:with="pageTitle='版本历史记录'">
<head>
    <link rel="stylesheet" th:href="@{/css/index.css}">
    <style>
        .text {
            font-size: 14px;
        }

        .item {
            margin-bottom: 18px;
        }

        .clearfix:before,
        .clearfix:after {
            display: table;
            content: "";
        }

        .clearfix:after {
            clear: both
        }

        .box-card {
            text-align: left;
            width: 480px;
            display: inline-block;
        }

        .el-row .el-col {
            text-align: left;
        }
    </style>
</head>
<body>
<th:block layout:fragment="custom_content">
    <input type="hidden" id="id"/>
    <el-form :inline="true" >
        <el-button type="primary" size="mini" @click="goback">返回</el-button>
        <el-table :data="tableData" v-loading.body="loading" stripe style="width: 940px;margin-top:10px">
            <el-table-column prop="version" label="序号" width="100"></el-table-column>
            <el-table-column prop="title" label="文件名" width="400"></el-table-column>
            <el-table-column prop="operator" label="操作人" width="150"></el-table-column>
            <el-table-column prop="createTime" label="更新时间" :formatter="dateFormat" width="180"></el-table-column>
            <el-table-column label="操作" width="80">
                <template scope="scope">
                    <el-button size="mini" type="primary" @click="edit(scope.row.id)">编辑</el-button>
                </template>
            </el-table-column>
        </el-table>
    </el-form>
</th:block>
<th:block layout:fragment="javascript">
    <script th:src="@{/moment.js}"></script>
    <script>
        var indexVue = new Vue({
            el: '#app',
            data: function () {
                return {
                    siderWidthDialog:false,
                    siderbarWidth:15,
                    tableData: [],
                    loading: false,
                    pageNum: 0,
                    breadcrumbs:['版本历史记录'],
                    isCollapse: false,
                    defaultIndex: '1',
                    menus: [],
                    regulationMenus: [],
                    deptTrees:[]
                }
            },
            methods: {
                addHeight: function () {
                    var $this = this;
                    $this.$nextTick(function () {
                        changeFooterHeight();
                    })
                },
                goback: function () {
                    var id = $("#id").val();
                    location.href = "/regulation/showregulation/"+id;
                },
                edit: function (id) {
                    // sessionStorage.setItem("his_id", id);
                    var rule_id = $("#id").val();
                    location.href = "/regulation/showregulationhis/"+rule_id+"/"+id;
                },
                //时间格式化
                dateFormat: function (row, column) {
                    var date = row[column.property];
                    if (date == undefined) {
                        return "";
                    }
                    return moment(date).format("YYYY-MM-DD HH:mm:ss");
                },
                initMenu: function () {
                    var $this = this;
                    var data = commonInitMenu($this);
                },
                toggleMenu: function () {
                    this.isCollapse = !this.isCollapse;
                    window.localStorage.setItem('isCollapse',this.isCollapse);
                },
                changeSiderWidth:function(value){
                    changeSiderWidth(this,value);
                },
                openChangeSiderWidth:function(){
                    this.siderWidthDialog=true;
                }
            },
            created: function () {
                initCssProperty(this);
            }
        });

        function init() {
            indexVue.initMenu();
        }

        function search(pageNum, id) {
            indexVue.loading = true;
            var condition = {};
            if(indexVue.pageNum==0){
                indexVue.pageNum = 1;
            }
            condition['pageNum'] = indexVue.pageNum;
            condition['ruleId'] = id;
            $.ajax({
                cache: true,
                url: '/regulation/listversion?newDate='+Math.random(),
                type: 'POST',
                data: JSON.stringify(condition),
                dataType: 'json',
                contentType: 'application/json',
                async: false,
                success: function (data) {
                    indexVue.loading = false;
                    if (data.status == 1) {
                        var pageInfo = data.value;
                        indexVue.tableData = pageInfo.list;
                        indexVue.addHeight();
                    }
                }
            });
        }

        $(function () {
            init();
            var strs = location.href.split("/");
            var id = strs[strs.length - 1];

            $("#id").val(id);
            search(1, id);
            changeFooterHeight();
        })
    </script>
</th:block>
</body>
</html>